package ClassWork.Job01;

import java.io.*;

/**
 * @author 培培
 * @condition 努力学习中
 */
public class Job01 {
    public static void main(String[] args) throws IOException {
        String filePath = "d:\\mytemp";

        File file = new File(filePath);
        if (!file.exists()){
            //创建
            if (file.mkdirs()){
                System.out.println("创建" + filePath + " 创建成功");
            }else {
                System.out.println("创建" + filePath + " 创建失败");
            }
        }

        String path = filePath + "\\hello.txt";
        file = new File(path);
        if (!file.exists()){
            if (file.createNewFile()){
                System.out.println(path + "创建成功");

                //如果文件存在，使用BufferedWriter
                BufferedWriter br = new BufferedWriter(new FileWriter(file));
                br.write("hello,world~~~");
                br.close();
            }else{
                System.out.println(path + "创建失败");
            }
        }else {
            System.out.println(path + "文件已经存在，不再重复创建");
        }

    }
}
